<template>
  <!-- 添加或修改【请填写功能名称】对话框 -->
  <el-dialog title="查看发布" :visible.sync="open" width="700px" append-to-body @close="cancel">
    <el-form ref="form" :model="form"  label-width="80px">
      <el-row>
        <el-col :span="22" style="height: 55px;">
          <el-form-item label="主题" prop="policyThemes">
            <el-input v-model="form.policyThemes" placeholder="请输入主题" disabled="true" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="22" style="height: 55px;">
          <el-form-item label="原文网址" prop="website">
            <el-input v-model="form.website" placeholder="请输入原文网址" disabled="true" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="22" style="height: 55px;">
          <el-form-item label="发布类型" prop="sendType">
            <el-select v-model="form.sendType" placeholder="请选择发布类型" style="width: 525px;"
                       disabled="true">
              <el-option v-for="dict in dict.type.release_type" :key="dict.value" :label="dict.label"
                         :value="dict.value"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="11" style="height: 55px;">
          <el-form-item label="创建人" prop="creationName">
            <el-input v-model="form.creationName" disabled />
          </el-form-item>
        </el-col>
        <el-col :span="11" style="height: 55px;">
          <el-form-item label="创建时间" prop="creationTime">
            <el-input v-model="form.creationTime" disabled />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="22" style="height: 114px;">
          <el-form-item label="内容" prop="content">
            <el-input v-model="form.content" type="textarea" placeholder="请输入政策内容" :rows="4"
                      style="width: 525px;" disabled />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12" style="height: 85px;">
          <el-form-item label="附件">
            <file-view :key="refreshKey" :type="fileType" :businessId="businessId"
                       :businessCode="releaseFile"></file-view>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer" style="margin-top: 8px;  justify-content: center; display: flex; /* 水平居中 */">
      <el-button @click="cancel" >关 闭</el-button>
    </div>
  </el-dialog>
</template>
<script>
import { listReleaseManagement, getManagement, delManagement, addManagement, updateManagement } from "@/api/release/release";
import FileView from "@/components/FileView/index"
export default {
  name: "DigRelease",
  props:{
    id:{
      type: String,
      default: false
    }
  },
  dicts: ['release_type'],
  components: { FileView },
  data(){
    return{
      fileType: 0,
      fileType2: 0,
      refreshKey: 0,
      businessId: null,
      releaseFile: "releaseFile",
      releasePictrue: "releasePictrue",
      form:{},
      open:false
    }
  },
  created() {
    this.handleView(this.id);
  },
  watch: {
    // 监听 id 属性的变化
    id(newId) {
      this.handleView(newId);
    }
  },
  methods:{
    // 取消按钮
    cancel() {
      this.open = false;
      this.$emit('custom-event', false);
      this.reset();
    },
    reset(){
      this.form={};
    },
    handleView(id) {
      this.reset();
      this.fileType = 2;
      this.fileType2 = 2;
      this.businessId = id;
      this.isShow = false;
      getManagement(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "查看发布管理信息";
      });
      this.refreshKey++;
      this.disabled = true;
    },
  }
}
</script>
<style scoped>

</style>
